Skip to content

Optimize static site generation: extract CSS, add minification, consolidate workflow#2

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/improve-code-performance
Draft

Optimize static site generation: extract CSS, add minification, consolidate workflow#2
Copilot wants to merge 5 commits intomainfrom
copilot/improve-code-performance

Conversation

Copy link

Copilot AI commented Oct 31, 2025

Identified and eliminated performance bottlenecks in static site generation: inline CSS preventing browser caching, 84 lines of duplicate CSS in workflow fallback, redundant filesystem operations, and absence of minification.

Changes

CSS Optimization

  • Extract inline styles to styles.css (enables caching, reduces HTML 20%)
  • Consolidate duplicate properties: .header, .feed, .updated share background, border-radius, box-shadow, padding
  • Add minification step: 1.6KB → 1.2KB (25%)

HTML Optimization

  • Remove 2KB inline <style> block
  • Add minification: 10.6KB → 7.0KB (34%)
  • Replace hardcoded feed count with {{FEED_COUNT}} placeholder token

Workflow Optimization

  • Remove 84-line CSS fallback (now uses actual index.html + styles.css)
  • Consolidate file operations: single find execution for both copy and count (was executed twice)
  • Dynamic feed count calculation: FEED_COUNT=$(echo "$FEED_FILES" | wc -l)
  • Minify CSS/HTML as build step using clean-css-cli and html-minifier

Before:

if ls feeds/*.xml 1> /dev/null 2>&1; then
  cp feeds/*.xml _site/feeds/
fi
if ls feeds/*.rss 1> /dev/null 2>&1; then
  cp feeds/*.rss _site/feeds/
fi
# ...plus 80 more lines of duplicate CSS

After:

FEED_FILES=$(find feeds -type f \( -name "*.xml" -o -name "*.rss" ... \))
echo "$FEED_FILES" | xargs -I {} cp {} _site/feeds/
FEED_COUNT=$(echo "$FEED_FILES" | wc -l)

Impact

  • File sizes: HTML -34%, CSS -25%, workflow -41%
  • Build performance: Single filesystem traversal, streamlined operations
  • Browser performance: CSS caching enabled, reduced payload
  • Maintenance: Feed count auto-updates from filesystem

CodeQL: 0 alerts

Original prompt

Identify and suggest improvements to slow or inefficient code


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits October 31, 2025 15:46
- Extract CSS from inline styles to external styles.css for better caching
- Reduce HTML file size from 10,629 to 8,492 bytes (20% reduction)
- Consolidate workflow file operations, removing redundant checks
- Remove 84 lines of duplicate CSS from workflow (59% reduction: 142→58 lines)
- Simplify feed file copying with single find operation

Co-authored-by: monk-blade <1335766+monk-blade@users.noreply.github.com>
- Implement CSS minification (1.6K → 1.2K, 25% reduction)
- Implement HTML minification (8.3K → 7.0K, 16% reduction)
- Make feed count dynamic based on actual files in feeds directory
- Auto-update feed count from hardcoded 20 to actual count (22)

Co-authored-by: monk-blade <1335766+monk-blade@users.noreply.github.com>
- Consolidate common styles for .header, .feed, and .updated classes
- Reduce CSS file size from 1,566 to 1,373 bytes (12% reduction)
- Streamline workflow minification process (remove intermediate file)

Co-authored-by: monk-blade <1335766+monk-blade@users.noreply.github.com>
- Use placeholder token {{FEED_COUNT}} instead of hardcoded text
- Eliminate duplicate find operations (store results in variable)
- Use more specific sed pattern for CSS link replacement
- Handle edge case when no feed files exist (set count to 0)

Co-authored-by: monk-blade <1335766+monk-blade@users.noreply.github.com>
Copilot AI changed the title [WIP] Identify and suggest improvements to inefficient code Optimize static site generation: extract CSS, add minification, consolidate workflow Oct 31, 2025
Copilot AI requested a review from monk-blade October 31, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants